/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.eurotrader.exclusao;

import br.com.eurotrader.controller.BaseController;
import br.com.eurotrader.interfaces.InterfaceEntidades;
import br.com.eurotrader.utils.FacesUtils;
import br.com.eurotrader.utils.MetodosBotoes;
import javax.faces.event.ActionEvent;
import javax.inject.Named;

/**
 *
 * @author PROG01
 */
@Named
public class ConfirmaExclusao {

    private boolean renderizaConfirmaExclusao = false;

    public boolean isRenderizaConfirmaExclusao() {
        return renderizaConfirmaExclusao;
    }

    public void setRenderizaConfirmaExclusao(boolean renderizaConfirmaExclusao) {
        this.renderizaConfirmaExclusao = renderizaConfirmaExclusao;
    }

    public void cancelarExclusao(ActionEvent event) {
        renderizaConfirmaExclusao = false;
    }

    public void abrirConfirmacaoDeExclusao(ActionEvent event) {
        System.out.println("abrirConfirmacaoDeExclusao");
        BaseController controler = ((MetodosBotoes) FacesUtils.getManagedBean("botoes")).getControllerPagina();
        if ((controler.getObjeto() != null) && (((InterfaceEntidades) controler.getObjeto()).getId()!=null)) {
            System.out.println("renderizaConfirmaExclusao");
            renderizaConfirmaExclusao = true;
        }
    }

    public void confirmarExclusao(ActionEvent event) {
        renderizaConfirmaExclusao = false;
        BaseController controler = ((MetodosBotoes) FacesUtils.getManagedBean("botoes")).getControllerPagina();
        controler.excluir(event);
    }
}
